package com.oa.system.service.impl;

import com.joneying.common.annotation.CommonService;
import com.oa.core.PageResult;
import com.oa.system.entity.RuleDescription;
import com.oa.system.mapper.RuleDescriptionMapper;
import com.oa.system.service.IRuleDescriptionService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;

/**
 * <p>
 * 规则说明表 服务实现类
 * </p>
 *
 * @author syb123
 * @since 2019-01-29
 */
@Service
public class RuleDescriptionServiceImpl extends ServiceImpl<RuleDescriptionMapper, RuleDescription> implements IRuleDescriptionService {

    private final RuleDescriptionMapper ruleDescriptionMapper;

    @Autowired
    public RuleDescriptionServiceImpl(RuleDescriptionMapper ruleDescriptionMapper) {
        this.ruleDescriptionMapper = ruleDescriptionMapper;
    }

    @Override
    @CommonService
    public PageResult<RuleDescription> findList(Integer pageNum, Integer pageSize) {
        if(pageNum == null){
            List<RuleDescription> list = ruleDescriptionMapper.findList();
            return new PageResult<>(list);
        }else{
            // 当前页，总条数 构造 page 对象
            Page<RuleDescription> page = new Page<>(pageNum, pageSize);
            //查询
            List<RuleDescription> list = ruleDescriptionMapper.findList(page);
            return new PageResult<>(list);
        }
    }

    /**
    * 根据id查询
    */
    @Override
    @CommonService
    public RuleDescription findRuleDescriptionById(String id){
        return ruleDescriptionMapper.findById(id);
    }
}
